/* GUI CONVERTED from ececmtc.p (converter v1.76) Mon May 12 22:54:38 2003 */
/* ececmtc.p - SCROLLING PROCESS SELECTION MENU (PCO/PCR)                     */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.12.1.12 $                                                     */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.4      LAST MODIFIED: 07/12/93   BY: pma *H013*                */
/* REVISION: 7.4      LAST MODIFIED: 07/08/94   BY: pma *H434*                */
/* REVISION: 7.4      LAST MODIFIED: 08/12/94   BY: qzl *H480* sr103110       */
/* REVISION: 7.4      LAST MODIFIED: 10/27/94   BY: ame *H578*                */
/* REVISION: 8.5      LAST MODIFIED: 11/22/95   BY: tvo *J094*                */
/* REVISION: 8.5      LAST MODIFIED: 04/23/96   BY: jpm *J0JX*                */
/* REVISION: 8.6      LAST MODIFIED: 12/05/96   BY: Joe Gawel    *K00C*       */
/* REVISION: 8.6      LAST MODIFIED: 01/02/97   BY: Joe Gawel    *K048*       */
/* REVISION: 8.6      LAST MODIFIED: 01/03/97   BY: Joe Gawel    *K04B*       */
/* REVISION: 8.6      LAST MODIFIED: 03/18/97   BY: Verghese Kurien *K07Q*    */
/* REVISION: 8.6      LAST MODIFIED: 06/18/97   BY: Joe Gawel    *K0F6*       */
/* REVISION: 8.6      LAST MODIFIED: 07/07/97   BY: Joe Gawel    *K0F4*       */
/* REVISION: 8.6      LAST MODIFIED: 12/05/97   BY: Viji Pakala  *K1C5*       */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder      */
/* REVISION: 9.1      LAST MODIFIED: 08/24/00   BY: *N0MZ* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.12.1.7      BY: Katie Hilbert    DATE: 05/25/02  ECO: *P072*   */
/* Revision: 1.12.1.8      BY: Vandna Rohira    DATE: 06/11/02  ECO: *N1L1*   */
/* Revision: 1.12.1.11     BY: Jean Miller      DATE: 06/20/02  ECO: *P09H*   */
/* $Revision: 1.12.1.12 $   BY: Amit Chaturvedi  DATE: 05/07/03  ECO: *N2F0*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input  parameter ecm_recid  as   recid.
define input  parameter section    as   integer.
define input  parameter mtitle     like mnt_label.
define output parameter prog_type  as   character.
define output parameter prog_name  like mnd_exec.
define output parameter prog_title as   character format "x(40)".

define temp-table sellist
   field t_sequence as integer
   field sel        as character format "x(50)"
   index t_seqsel is primary
      t_sequence ascending.

define shared variable global_passwd      as character.
define shared variable global_user_groups as character format "x(60)"
   label "Groups".
define variable ilist         as   character               no-undo.
define variable s_array       like sel      extent 100     no-undo.
define variable p_array       like mnd_exec extent 100     no-undo.
define variable k             as   integer                 no-undo.
define variable ecr_ecn       as   character format "x(3)" no-undo.
define variable can_do_menu   as   logical                 no-undo.
define variable user_excluded like mfc_logical             no-undo.
define variable group_indx    as   integer                 no-undo.
define variable tmp_canrun    as   character               no-undo.

define buffer mnddet for mnd_det.

{ecwndvar.i}  /* SCROLLING WINDOW VARIABLES */

/* NOTE:  THE FOLLOWING SECTION EXISTS TO ENSURE THAT THE CALLED  */
/*        ARE INCLUDED IN ALL PROGRAM LISTINGS.  AS NEW FUNCTIONS */
/*        ARE DEVELOPED, THEY MUST BE ADDED TO THIS LIST.         */

if false
then do:

   {gprun.i ""ecmt00.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Null Program                         */
   {gprun.i ""ecmt01.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Change PCR/PCO Number                */
   {gprun.i ""ecmt02.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Copy, Close, Convert PCR/PCO         */
   {gprun.i ""ecmt03.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Copy Text from Master Comments       */
   {gprun.i ""ecmt04.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Add, Modify, Delete Text Data        */
   {gprun.i ""ecmt05.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Direct Item Master Access            */
   {gprun.i ""ecmt06.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Add, Modify, Delete Item Data        */
   {gprun.i ""ecmt07.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Add, Modify, Deactivate Structures   */
   {gprun.i ""ecmt08.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Copy Product Structures into PCO     */
   {gprun.i ""ecmt09.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Where Used Copy to PCO               */
   {gprun.i ""ecmt10.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Replace Component                    */
   {gprun.i ""ecmt100.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
  /*if not can-do menu                   */
   {gprun.i ""ecmt11.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Copy Routing to PCO/PCR              */
   {gprun.i ""ecmt12.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Add/Edit/Deact Routing               */
   {gprun.i ""ecmt13.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
   /*Add/Edit/Deact Routing (Rate Based)  */
   {gprun.i ""ecqmcpy.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
  /*Copy Item Spec to PCC from Qual Mod  */
   {gprun.i ""ececd4mt.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
 /*Add/Edit/Deactivate Item Spec        */

   {gprunex.i &module='QS' &subdir='' &program='ecqscpy.p'}

   {gprunex.i &module='QS' &subdir='' &program='pcmt08.p'}
end. /* IF false */

for first ecm_mstr
   fields(ecm_doc_type)
   where recid(ecm_mstr) = ecm_recid
   no-lock:
end. /* FOR FIRST ecm_mstr */

if not available ecm_mstr
then do:

   hide frame w1.
   return.
end. /* IF NOT AVAILABLE ecm_mstr */

ecr_ecn = string(ecm_doc_type).

for each sellist
   exclusive-lock:
   delete sellist.
end. /* FOR EACH sellist */

assign
   s_array = fill("X",50)

   s_array[1]  = getTermLabel("CONVERT_PCR_TO_PCO",45)
   p_array[1]  = "ecmt02.p"

   s_array[2]  = if ecm_doc_type = "PCR"
                 then
                    getTermLabel("CHANGE_PCR_NUMBER",45)
                 else
                    getTermLabel("CHANGE_PCO_NUMBER",45)

   p_array[2]  = "ecmt01.p"

   s_array[3]  = getTermLabel("CLOSE",15) + " " + ecr_ecn + " " +
                 getTermLabel("TO",4) + " " + getTermLabel("PCO",6)
   p_array[3]  = "ecmt02.p"

   s_array[4]  = getTermLabel("COPY",10) + " " + ecr_ecn + " " +
                 getTermLabel("FROM",6)  + " " + getTermLabel("PCO/PCR",14)
   p_array[4]  = "ecmt02.p"

   s_array[5]  = getTermLabel("ADD",8) + ", " + getTermLabel("MODIFY",8)
               + ", " + getTermLabel("DELETE",8) + " " + ecr_ecn + " " +
                 getTermLabel("TEXT_DATA",12)
   p_array[5]  = "ecmt04.p"

   s_array[6]  = getTermLabel("COPY_TEXT_FROM_MASTER_COMMENTS_INTO",45)
               + " " + ecr_ecn
   p_array[6]  = "ecmt03.p"

   s_array[7]  = getTermLabel("ADD",8)    + ", " +
                 getTermLabel("MODIFY",8) + ", " +
                 getTermLabel("DELETE",8) + " " +
                 ecr_ecn + " " + getTermLabel("ITEM_DATA",12)
   p_array[7]  = "ecmt06.p"

   s_array[8]  = getTermLabel("DIRECT_ITEM_MASTER_ACCESS",45)
   p_array[8]  = "ecmt05.p"

   s_array[9] = getTermLabel("COPY_PRODUCT_STRUCTURE_INTO",35) + " " +
                 ecr_ecn
   p_array[9] = "ecmt08.p".

assign
   s_array[11] = getTermLabel("COPY_WHERE_USED_INTO",35) + " " + ecr_ecn
   p_array[11] = "ecmt09.p"

   s_array[13]  = getTermLabel("PCR/PCO_DETAIL_MAINTENANCE",28) + " - " +
                 getTermLabel("PRODUCT_STRUCTURES",19)
   p_array[13]  = "ecmt07.p"

   s_array[14] = getTermLabel("REPLACE_PRODUCT_STRUCTURE_COMPONENT",45)
   p_array[14] = "ecmt10.p"

   s_array[15] = getTermLabel("MASS_CHANGE_-_PARENT",45)
   p_array[15] = "ecmt00.p"

   s_array[16] = getTermLabel("MASS_CHANGE_-_COMPONENT",45)
   p_array[16] = "ecmt00.p"

   s_array[17] = getTermLabel("MASS_EDIT_PRODUCT_STRUCTURE_DATA",45)
   p_array[17] = "ecmt00.p"

   s_array[18] = getTermLabel("MASS_REPLACE_PS_COMPONENT",45)
   p_array[18] = "ecmt00.p"

   s_array[19] = getTermLabel("MASS_DEACTIVATE_PS_COMPONENT",45)
   p_array[19] = "ecmt00.p"

   s_array[20] = getTermLabel("MASS_OBSOLETE_PRODUCT_STRUCTURE",45)
   p_array[20] = "ecmt00.p".

assign
   s_array[21] = getTermLabel("COPY_FORMULA_INTO",35) + " " + ecr_ecn
   p_array[21] = "ecmt08.p"

   s_array[23] = getTermLabel("COPY_WHERE_USED_INTO",35) + " " +
                 ecr_ecn
   p_array[23] = "ecmt09.p"

   s_array[25] = getTermLabel("PCR/PCO_DETAIL_MAINTENANCE",30) + " - " +
                 getTermLabel("FORMULAS",15)
   p_array[25] = "ecmt07.p"

   s_array[26] = getTermLabel("REPLACE_FORMULA_COMPONENT",45)
   p_array[26] = "ecmt10.p"

   s_array[27] = getTermLabel("MASS_CHANGE_-_PARENT",45)
   p_array[27] = "ecmt00.p"

   s_array[28] = getTermLabel("MASS_CHANGE_-_COMPONENT",45)
   p_array[28] = "ecmt00.p"

   s_array[29] = getTermLabel("MASS_EDIT_FORMULA_DATA",45)
   p_array[29] = "ecmt00.p"

   s_array[30] = getTermLabel("MASS_REPLACE_FORMULA_COMPONENT",45)
   p_array[30] = "ecmt00.p".

assign
   s_array[31] = getTermLabel("MASS_DEACTIVATE_FORMULA_COMPONENT",45)
   p_array[31] = "ecmt00.p"

   s_array[32] = getTermLabel("MASS_OBSOLETE_FORMULA",45)
   p_array[32] = "ecmt00.p"

   s_array[33]  = getTermLabel("COPY",10) + " " + ecr_ecn + " " +
                 getTermLabel("TO",4)    + " " + getTermLabel("PCO/PCR",16)
   p_array[33]  = "ecmt02.p"

   s_array[34] = getTermLabel("COPY_ROUTING_TO_PCR/PCO",45)
   p_array[34] = "ecmt11.p"

   s_array[35] = getTermLabel("PCR/PCO_DETAIL_MAINTENANCE",35) + " - " +
                 getTermLabel("ROUTING",12)
   p_array[35] = "ecmt12.p"

   s_array[36] = getTermLabel("PCR/PCO_DETAIL_MAINTENANCE",28) + " - " +
                 getTermLabel("ROUTING_(RATE_BASED)",22)
   p_array[36] = "ecmt13.p"

   s_array[37] = getTermLabel("COPY_PROCESSES_TO_PCR/PCO",45)
   p_array[37] = "ecmt11.p"

   s_array[38] = getTermLabel("PCR/PCO_DETAIL_MAINTENANCE",30) + " - " +
                 getTermLabel("PROCESSES",16)
   p_array[38] = "ecmt12.p"

   s_array[39] = getTermLabel("COPY_ITEM_SPECIFICATION_FROM_QM",45)
   p_array[39] = "ecqmcpy.p"

   s_array[40] = getTermLabel("PCR/PCO_DETAIL_MAINTENANCE",28) + " - " +
                 getTermLabel("ITEM_SPECIFICATION",19)
   p_array[40] = "ececd4mt.p".

/* ADD POTENTIAL PASSWORD/MENU PROTECTION */
do k = 1 to 99:

   can_do_menu = yes.

   for first mnddet
      fields(mnd_exec mnd_canrun)
      where mnd_exec = p_array[k]
      no-lock:
      {mfsec.i "mnddet"}
   end. /* FOR FIRST mnddet */

   if p_array[k] = "ecmt05.p"
   then do:

      for first mnddet
         fields(mnd_exec mnd_canrun)
         where mnd_exec = "ppptmt04.p"
         no-lock:
         {mfsec.i "mnddet"}
      end. /* FOR FIRST mnddet */

   end. /* IF p_array[k] = "ecmt05.p" */

   if not can_do_menu
   then
      p_array[k] = "ecmt100.p".
end. /* DO k = 1 to 99: */

ilist = "".

if section = 1
   and ecm_doc_type = "PCR"
then                                /*PCR*/
   ilist = "1,2,3,4,33".
else
if section = 1
then                                /*ECN*/
   ilist = "2,3,4,33".
else
if section = 2
then                                /*TEXT*/
   ilist = "5,6".
else
if section = 3
then                                /*ITEM*/
   ilist = "7,8".
else
if section = 4
then                                /*STRUCTURE*/
   ilist = "9,11,13,14".
else
if section = 5
then                                /*ROUTING*/
   ilist = "34,35,36".
else
if section = 6
then                                /*FORMULA*/
   ilist = "21,23,25,26".
else
if section = 7
then                                /*PROCESS*/
   ilist = "37,38".
else
if section = 8
then                                /*TRAILER*/
   ilist = "".
else
if section = 9
then                                /*SPECIFICATION*/
   ilist = "39,40".


/* SELECT ECN PROCEDURE WINDOW */
do k = 1 to 100:
   if can-do(ilist, string(k))
   then do:

      create sellist.
      assign
         t_sequence = k
         sel        = s_array[k].
   end. /* IF can-do(ilist, string(k)) */
end. /* DO k = 1 to 100 */

assign
   window_row  = 9
   window_down = 9.

if mtitle = ""
then
   mtitle = getTermLabel("SELECT_PCR/PCO_PROCEDURE",35).

repeat:

   /* global_recid IS SET TO FIRST RECORD OF sellist TO START THE */
   /* DISPLAY FROM FIRST RECORD                                   */

   for first sellist
      no-lock :
      global_recid = recid(sellist).
   end. /* FOR FIRST sellist */

   /* REMOVED TABLE REFERENCE FROM 2nd, 3rd, 5th AND 9th PARAMETER */
   /* REPLACED 4th PARAMETER FROM "/**/"                           */
   {ecwindow.i sellist
      "sel no-label"
      sel
      "use-index t_seqsel"
      "sel <> fill('X',40)"
      mtitle
      "no-labels width 55 centered attr-space"
      "2"
      sel}

   if lastkey = keycode("GO")
      or lastkey = keycode("F1")
      or lastkey = 301
      or keyfunction(lastkey) = "GO"
      or lastkey = keycode("RETURN")
   then do:

      assign
         prog_name = "ecmt00.p"
         prog_title = "".

      arrayloop:
      do k = 1 to 100:
         if ix1array[i] = s_array[k]
         then do:

            assign
               prog_name  = p_array[k]
               prog_type  = "T-" + string(k,"99")
               prog_title = trim(prog_name) + "  " + trim(s_array[k]).
            hide frame w1.
            return.
         end. /* IF ix1array[i] = s_array[k] */
      end. /* DO k = 1 to 100 */

      global_recid = recidarray[i].

      hide frame w1.
      return.

   end. /* IF F1 OR GO */

   else do:

      assign
         frame-value = frame_val_save
         global_recid = ?.

      if keyfunction(lastkey)    = "end-error"
         or keyfunction(lastkey) = "endkey"
         or lastkey = keycode("F4")
      then do:

         hide frame w1.
         return.
      end. /* IF keyfunction(lastkey) = "end-error" */

      apply lastkey.

   end. /* ELSE DO */

end. /* REPEAT */
